#pragma once
#include "Actor.h"
#include "Time.h"
#include "MouseInput.h"
#include "KeyboardInput.h"
#include "InputController.h"
#include "cubePlain.h"

#include "myWindowHeader.h"
#include "Resource.h"

#include "myMatrix.h"

#include "RendererFactory.h"
#include <vector>
#include "Matrix.h"
#define PI 3.1415926f
//using namespace bEngine;
using namespace NBE;
namespace banknamespace
{
	

	class OpenGLApp
	{
		RendererFactory rFac;
		const char* rendermode;

		HWND m_hWnd;
		HACCEL m_hAccelTable;
		HDC m_hdcWindow;
		HGLRC m_renderingContext;
		
		Actor m_camera;

		spacehax::SystemClocks nextFrameTime;
		spacehax::SystemClocks lastTime;

		unsigned int frameCounter;

		
		GLuint stoneid;
		GLuint trollid;
		GLuint defaultid;
		Actor stonecam;

		Actor originCube;
		Actor square;
		
		

		float cubeSize;
		Actor cube;
		cubePlain plain;
		Actor plainActor;
		float plainSize;

		//float ball->ballSize;
		std::vector<Actor*> ballVec;

		vec3f lightPos;
		vec3f lightPos2;

		Actor test;
	public:
		int currentModel;
		class InitFailed {};

		OpenGLApp( HINSTANCE hInstance, int nCmdShow );

		virtual ~OpenGLApp();
		//void setShaders();

		int RunMainLoop();

		virtual void UpdateFrame();
		Actor* addAball(float size);
		void clearBall();
	protected :
	private:
		 
		//void InitializeOpenGL()
		//{
		//	assert( m_hdcWindow );

		//	// Set the window pixel format
		//	//
		//	PIXELFORMATDESCRIPTOR pixelFormatDescriptor = {0};

		//	pixelFormatDescriptor.nSize = sizeof( pixelFormatDescriptor );
		//	pixelFormatDescriptor.nVersion = 1;

		//	pixelFormatDescriptor.dwFlags = 
		//		PFD_DRAW_TO_WINDOW | 
		//		PFD_SUPPORT_OPENGL | 
		//		PFD_DOUBLEBUFFER;
		//	pixelFormatDescriptor.dwLayerMask = PFD_MAIN_PLANE;
		//	pixelFormatDescriptor.iPixelType = PFD_TYPE_RGBA;
		//	pixelFormatDescriptor.cColorBits = 32;
		//	pixelFormatDescriptor.cDepthBits = 32;

		//	int pixelFormat = ChoosePixelFormat( m_hdcWindow, &pixelFormatDescriptor );
		//	assert (pixelFormat != 0);
		//	SetPixelFormat( m_hdcWindow, pixelFormat, &pixelFormatDescriptor );

		//	// Create the OpenGL render context
		//	//
		//	m_renderingContext = wglCreateContext( m_hdcWindow );
		//	wglMakeCurrent ( m_hdcWindow, m_renderingContext );
		//	//g_hGLRenderingContext = m_renderingContext;

		//	// Hook up the main and local rendering contexts so that they share the same VBOs and such
		//	//g_hGLRenderingContextForPrecaching = wglCreateContext( m_hdcWindow );
		//	
		//	//BOOL success = wglShareLists( g_hGLRenderingContext, g_hGLRenderingContextForPrecaching );
		//	//assert( success );

		//	glewInit();

		//	glEnable( GL_DEPTH_TEST );

		//	//return m_renderingContext;
		//}

		//void ShutdownOpenGL()
		//{
		//	//wglDeleteContext( g_hGLRenderingContextForPrecaching );
		//	//g_hGLRenderingContextForPrecaching = 0;

		//	wglMakeCurrent( NULL, NULL );
		//	wglDeleteContext( m_renderingContext );
		//	m_renderingContext = 0;
		//}
	};
 

}
